package arrays;
import java.util.Arrays;
public class Test {
    public static int removeElement(int[] nums, int val) {
        int left = 0;
        int right = nums.length;
        while (left < right) {
            if (nums[left] == val) {
                nums[left] = nums[right - 1];
                right--;
            } else {
                left++;
            }
        }
        return left;
    }
    public int removeDuplicates(int[] nums) {
        int slow = 0;
        int fast = slow + 1;
        while(fast != nums.length){
            if(nums[slow] != nums[fast]){
                slow++;
                nums[slow] = nums[fast];
            }
            else{
                fast++;
            }
        }
        return slow + 1;
    }
    public static void main(String[] args){

        int[] arr = {3,2,2,3};
        int val = removeElement(arr,3);
        for(int i = 0; i < val; i++){
            System.out.print(arr[i]);
        }
    }
}
